import java.util.Iterator;
import java.util.Scanner;


public class Employee {

	/**
	 * @param args
	 */
	protected TimeSheet timeSheet;
	protected String id;
	protected int payPerHour;
	protected int minutesWorked;
	public static void main(String[] args) {
		
		Employee m = new Employee();
		m.addNewTimeSheet();
		m.processTimeSheet();
		System.out.println(m.getMinutesWorked());
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public int getPayPerHour() {
		return payPerHour;
	}

	public void setPayPerHour(int payPerHour) {
		this.payPerHour = payPerHour;
	}

	public int getMinutesWorked() {
		return minutesWorked;
	}

	public void setMinutesWorked(int minutesWorked) {
		this.minutesWorked = minutesWorked;
	}

	public TimeSheet getTimeSheet() {
		return timeSheet;
	}

	public void setTimeSheet(TimeSheet timeSheet) {
		this.timeSheet = timeSheet;
	}
	
	public void processTimeSheet() {
		Iterator<Interval> iterator = timeSheet.iterator();
		int count = 0;
		while (iterator.hasNext()) {
			Interval interval = iterator.next();
			if((interval.getClockIn().getMinute() > 480) | (interval.getClockOut().getMinute() < 1020))
			{}
			else
			{
				count+= interval.getDuration();
			}	
		}
		minutesWorked = count;
	}
	
	public int getPay() {
		int money = (minutesWorked/60) * payPerHour;
		return money;
	}
	
	public void resetMinutesWorked() {
		timeSheet.clear();
		setMinutesWorked(0);
	}
	
	public void addNewTimeSheet() {
		timeSheet = new TimeSheet();
		Scanner in = new Scanner(System.in);
		int day;
		int minute;
		int clockOutMinute;
		for(int i = 0; i < 2; i++)
		{
			System.out.println("Input inteval day " + i+1 +": ");
			System.out.println("Input clock in: " );
			System.out.println("Input clock in day:" );
			day = in.nextInt();
			System.out.println("Input clock in minute:" );
			minute = in.nextInt();
			TimeStamp clockIn = new TimeStamp(day, minute);
			System.out.println("Input clock out: " );
			System.out.println("Input clock out day:" );
			day = in.nextInt();
			System.out.println("Input clock out minute:" );
			minute = in.nextInt();
			TimeStamp clockOut = new TimeStamp(day, minute);
			Interval inteval = new Interval(clockIn, clockOut);
			
			timeSheet.addInterval(inteval);
		}
	}
}
